package com.louzhu.gulimall.cart.config;

import com.louzhu.gulimall.cart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截器
 */
@Configuration
public class GulimallWebConfig implements WebMvcConfigurer {
    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加购物车拦截器 CartInterceptor ，指定拦截路径为 当下的所有请求
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");

    }
}
